# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libpsl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.21.1
pkgrel=2
pkgdesc="Public Suffix List library (mingw-w64)"
arch=('any')
url="https://github.com/rockdaboot/libpsl"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libidn2"
         "${MINGW_PACKAGE_PREFIX}-libunistring"
         "${MINGW_PACKAGE_PREFIX}-gettext")
makedepends=("${MINGW_PACKAGE_PREFIX}-libxslt"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-gettext"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://github.com/rockdaboot/libpsl/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('ac6ce1e1fbd4d0254c4ddb9d37f1fa99dec83619c1253328155206b896210d4c')

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  LDFLAGS+=" -liconv"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Ddemos=true \
    -Dwidgetry=true \
    -Dgtk_doc=true \
    -Druntime=libidn2 \
    -Dbuiltin=libidn2 \
    --default-library both \
    ../${_realname}-${pkgver}

  ninja
}

package() {
  cd "${srcdir}"/build-${CARCH}
  DESTDIR="${pkgdir}" ninja install

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
